package xyz.kail.demo.consul.api;

import com.ecwid.consul.v1.ConsulRawClient;
import com.ecwid.consul.v1.QueryParams;
import com.ecwid.consul.v1.Response;
import com.ecwid.consul.v1.event.EventConsulClient;
import com.ecwid.consul.v1.event.model.Event;

import java.util.List;

/**
 * Consul实践指导-Watch机制： http://blog.csdn.net/younger_china/article/details/52243799
 *
 * @author Kail
 * @since 2018/1/15.
 */
public class EventHelloMain {

    public static void main(String[] args) {
        ConsulRawClient consulRawClient = new ConsulRawClient("localhost", 8500);
        EventConsulClient eventConsulClient = new EventConsulClient(consulRawClient);

        Response<List<Event>> eventList = eventConsulClient.eventList(QueryParams.Builder.builder().setWaitTime(100).setNear("asd").build());
        for (Event event : eventList.getValue()) {
            System.out.println(event);
        }


    }

}
